// 2025/07/27
// tag: 2D tree array
// Author: Forever
#include <bits/stdc++.h>
using namespace std;
#define lowbit(x) (x & -x)
const int MAXN = 2049;
int n, m, t1[MAXN][MAXN], t2[MAXN][MAXN], t3[MAXN][MAXN], t4[MAXN][MAXN];

void add(int x, int y, int v)
{
    for (int i = x; i <= n; i += lowbit(i))
        for (int j = y; j <= m; j += lowbit(j))
            t1[i][j] += v, t2[i][j] += v * x, t3[i][j] += v * y, t4[i][j] += v * x * y;
}

void range_add(int xa, int ya, int xb, int yb, int v)
{
    add(xa, ya, v);
    add(xa, yb + 1, -v);
    add(xb + 1, ya, -v);
    add(xb + 1, yb + 1, v);
}

int sum(int x, int y)
{
    int res = 0;
    for (int i = x; i; i -= lowbit(i))
        for (int j = y; j; j -= lowbit(j))
            res += t1[i][j] * (x + 1) * (y + 1) - t2[i][j] * (y + 1) - t3[i][j] * (x + 1) + t4[i][j];
    return res;
}

int range_sum(int xa, int ya, int xb, int yb)
{
    return sum(xb, yb) - sum(xa - 1, yb) - sum(xb, ya - 1) + sum(xa - 1, ya - 1);
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char c;
    int xa, ya, xb, yb, v;
    cin >> c >> n >> m;
    while (cin >> c)
    {
        if (c == 'L')
        {
            cin >> xa >> ya >> xb >> yb >> v;
            range_add(xa, ya, xb, yb, v);
        }
        else
        {
            cin >> xa >> ya >> xb >> yb;
            cout << range_sum(xa, ya, xb, yb) << endl;
        }
    }
    return 0;
}